HEX
Server: LiteSpeed
System: Linux lp015.web24.net.au 2.6.32-954.3.5.lve1.4.93.el6.x86_64 #1 SMP Wed Oct 4 17:04:29 UTC 2023 x86_64
User: pgkdistr (10190)
PHP: 8.1.32
Disabled: opcache_get_status
Upload Files
File: /var/www/vhosts/pgkdistribution.com.au/citisolar.com.au/functions.php
<?php

	//functions.php

	//This function will dump the cache of your browser, thereby ensuring the proper image loads,
	//not one that is simply stuck in the cache's memory.
	function clearcache (){
		//Clear the cache.
		header("Cache-control: private, no-cache");
		header("Expires: Mon, 26 Jun 1997 05:00:00 GMT");
		header("Pragma: no-cache");
	}
	
	//A function to create an array of all the images in the folder.
	function getImages (){
		$imgarr = array ();
		if (is_dir ($GLOBALS['imagesfolder'])){
			$mydir = scandir ($GLOBALS['imagesfolder']);
			//Loop through and find any valid images.
			for ($i = 0; $i < count ($mydir); $i++){
				//make sure it's a file
				if (is_file ($GLOBALS['imagesfolder'] . "/" . $mydir[$i])){
					//Check for a valid file type.
					$thepath = pathinfo ($GLOBALS['imagesfolder'] . "/" . $mydir[$i]);
					if (in_array ($thepath['extension'], $GLOBALS['allowedfiletypes'])){
						$imgarr[] = $mydir[$i];
					}
				}
			}
		}
		return ($imgarr);
	}

	//A function to retrieve a total number of images.
	function getImageCount ($imgarr){
		$totimages = 0;
		$totimages = count ($imgarr);
		return $totimages;
	}

	//A function to go through and retrieve an image location at a given index (numerical directory index).
	function getImageAtIndex ($imgarr, $index){
		//Return the file.
		return ($imgarr[$index]);
	}
	
	function setWidthHeight($width, $height, $maxWidth, $maxHeight){
		$ret = array($width, $height);
		$ratio = $width / $height;
		if ($width > $maxWidth || $height > $maxHeight) {
			$ret[0] = $maxWidth;
			$ret[1] = $ret[0] / $ratio;
		
			if ($ret[1] > $maxHeight) {
				$ret[1] = $maxHeight;
				$ret[0] = $ret[1] * $ratio;
			}
		}
		return $ret;
	}
		
	
	
?>